/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "planilla_pago_det", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PlanillaPagoDet.findAll", query = "SELECT p FROM PlanillaPagoDet p"),
    @NamedQuery(name = "PlanillaPagoDet.findByCiEmp", query = "SELECT p FROM PlanillaPagoDet p WHERE p.planillaPagoDetPK.ciEmp = :ciEmp"),
    @NamedQuery(name = "PlanillaPagoDet.findByIdcargo", query = "SELECT p FROM PlanillaPagoDet p WHERE p.planillaPagoDetPK.idcargo = :idcargo"),
    @NamedQuery(name = "PlanillaPagoDet.findByIdcontrato", query = "SELECT p FROM PlanillaPagoDet p WHERE p.planillaPagoDetPK.idcontrato = :idcontrato"),
    @NamedQuery(name = "PlanillaPagoDet.findByIdplanillaPago", query = "SELECT p FROM PlanillaPagoDet p WHERE p.planillaPagoDetPK.idplanillaPago = :idplanillaPago"),
    @NamedQuery(name = "PlanillaPagoDet.findByPlanillaPagoFecha", query = "SELECT p FROM PlanillaPagoDet p WHERE p.planillaPagoDetPK.planillaPagoFecha = :planillaPagoFecha"),
    @NamedQuery(name = "PlanillaPagoDet.findByMonto", query = "SELECT p FROM PlanillaPagoDet p WHERE p.monto = :monto")})
public class PlanillaPagoDet implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PlanillaPagoDetPK planillaPagoDetPK;
    @Column(name = "monto")
    private Integer monto;
    @JoinColumns({
        @JoinColumn(name = "idplanilla_pago", referencedColumnName = "idplanilla_pago", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "planilla_pago_fecha", referencedColumnName = "fecha", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private PlanillaPago planillaPago;
    @JoinColumns({
        @JoinColumn(name = "idcontrato", referencedColumnName = "idcontrato", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "idcargo", referencedColumnName = "idcargo", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "ci_emp", referencedColumnName = "ci_emp", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Contrato contrato;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "planillaPagoDet")
    private Collection<OrdenPagoSueldoDet> ordenPagoSueldoDetCollection;

    public PlanillaPagoDet() {
    }

    public PlanillaPagoDet(PlanillaPagoDetPK planillaPagoDetPK) {
        this.planillaPagoDetPK = planillaPagoDetPK;
    }

    public PlanillaPagoDet(int ciEmp, int idcargo, int idcontrato, int idplanillaPago, Date planillaPagoFecha) {
        this.planillaPagoDetPK = new PlanillaPagoDetPK(ciEmp, idcargo, idcontrato, idplanillaPago, planillaPagoFecha);
    }

    public PlanillaPagoDetPK getPlanillaPagoDetPK() {
        return planillaPagoDetPK;
    }

    public void setPlanillaPagoDetPK(PlanillaPagoDetPK planillaPagoDetPK) {
        this.planillaPagoDetPK = planillaPagoDetPK;
    }

    public Integer getMonto() {
        return monto;
    }

    public void setMonto(Integer monto) {
        this.monto = monto;
    }

    public PlanillaPago getPlanillaPago() {
        return planillaPago;
    }

    public void setPlanillaPago(PlanillaPago planillaPago) {
        this.planillaPago = planillaPago;
    }

    public Contrato getContrato() {
        return contrato;
    }

    public void setContrato(Contrato contrato) {
        this.contrato = contrato;
    }

    @XmlTransient
    public Collection<OrdenPagoSueldoDet> getOrdenPagoSueldoDetCollection() {
        return ordenPagoSueldoDetCollection;
    }

    public void setOrdenPagoSueldoDetCollection(Collection<OrdenPagoSueldoDet> ordenPagoSueldoDetCollection) {
        this.ordenPagoSueldoDetCollection = ordenPagoSueldoDetCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (planillaPagoDetPK != null ? planillaPagoDetPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlanillaPagoDet)) {
            return false;
        }
        PlanillaPagoDet other = (PlanillaPagoDet) object;
        if ((this.planillaPagoDetPK == null && other.planillaPagoDetPK != null) || (this.planillaPagoDetPK != null && !this.planillaPagoDetPK.equals(other.planillaPagoDetPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.PlanillaPagoDet[ planillaPagoDetPK=" + planillaPagoDetPK + " ]";
    }
    
}
